package com.htthorizon.powersupply.service.impl;

import cn.hutool.core.date.DatePattern;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.htthorizon.powersupply.domain.RdsGridTgCurDf;
import com.htthorizon.powersupply.mapper.RdsGridTgCurDfMapper;
import com.htthorizon.powersupply.service.RdsGridTgCurDfService;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author Brilliant
 * @description 针对表【rds_grid_tg_power_df】的数据库操作Service实现
 * @createDate 2025-01-16 15:47:38
 */
@Service
public class RdsGridTgCurDfServiceImpl extends ServiceImpl<RdsGridTgCurDfMapper, RdsGridTgCurDf>
        implements RdsGridTgCurDfService {

    @Override
    public Map<String, Object> getChartCur(String meterId) {
        String dateDt = DatePattern.PURE_DATE_FORMAT.format(new Date());
        HashMap<String, Object> map = new HashMap<>();
        map.put("a", new String[96]);
        map.put("b", new String[96]);
        map.put("c", new String[96]);
        map.put("date", dateDt);

        LambdaQueryWrapper<RdsGridTgCurDf> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(RdsGridTgCurDf::getMeterId, meterId);
        wrapper.in(RdsGridTgCurDf::getPhaseFlg, "1", "2", "3");
        wrapper.eq(RdsGridTgCurDf::getDataDt, dateDt);
        List<RdsGridTgCurDf> list = this.list(wrapper);
        for (RdsGridTgCurDf rdsGridTgCurDf : list) {
            if ("1".equals(rdsGridTgCurDf.getPhaseFlg())) {
                String[] a = rdsGridTgCurDf.mapArray();
                map.put("a", a);
            } else if ("2".equals(rdsGridTgCurDf.getPhaseFlg())) {
                String[] b = rdsGridTgCurDf.mapArray();
                map.put("b", b);
            } else if ("3".equals(rdsGridTgCurDf.getPhaseFlg())) {
                String[] c = rdsGridTgCurDf.mapArray();
                map.put("c", c);
            }
        }
        return map;
    }


}




